package com.felight.objectReadWrite;

/**
 * This is a class which reads object from a file.
 */
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.ObjectInputStream;

public class Readfile {

	public static void main(String[] args) {

		try {
			FileInputStream fs = new FileInputStream("output1.txt");
			ObjectInputStream os = new ObjectInputStream(fs);

			Object St = os.readObject(); // This line will read data from the
											// file output1.txt
			if (St instanceof Student) {
				Student student = (Student) St;
				System.out.println(student.name);
				System.out.println(student.perc);
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
